<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../00_static/js/vue.js" type="text/javascript"></script>
    <title>条件渲染</title>
    <style>
        img {
            width: 150px;
            height: 150px;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- 
            v-if:
                适用于：切换频率很低的场景
                特点：不展示的DOM节点直接被删除
            
            V-show:
                适用于：切换频率很高的场景
                特点：不展示的DOM节点没有被删除，仅仅是使用样式隐藏掉
         -->

        <h2>今天天气很{{isHot ? '炎热' : '凉爽'}}</h2>
        <button @click="isHot = !isHot">切换天气</button><br><br>

        <!-- 只有天气炎热，才会展示下面的div -->
        <!-- <div v-show="isHot">
            <img src="../00_static/img/热.jpeg" alt=""><br>
            <span>建议：心境自然就会凉</span>
        </div> -->

        <!-- 只有天气凉爽，才会展示下面的div -->
        <!-- <div v-show="!isHot">
            <img src="../00_static/img/冷.jpeg" alt=""><br>
            <span>建议：要传秋裤啦！</span>
        </div> -->

        <!-- 只有天气炎热，才会展示下面的div -->
        <div v-if="isHot">
            <img src="../00_static/img/热.jpeg" alt=""><br>
            <span>建议：心境自然就会凉</span>
        </div>

        <!-- 只有天气凉爽，才会展示下面的div -->
        <div v-else>
            <img src="../00_static/img/冷.jpeg" alt=""><br>
            <span>建议：要传秋裤啦！</span>
        </div>
    </div>

    <script type="text/javascript">
        new Vue({
            el: '#app',
            data: {
                isHot: false
            }
        })
    </script>
</body>

</html>